package com.netease.nie.service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netease.nie.base.utils.CopyUtils;
import com.netease.nie.base.utils.CustomDateFormatUtils;
import com.netease.nie.dao.RobGoodsPeriodComputeResultDao;
import com.netease.nie.dto.RobGoodsPeriodComputeResultDto;
import com.netease.nie.model.RobGoodsPeriodComputeResult;

@Service
public class RobGoodsPeriodComputeResultServiceImpl implements RobGoodsPeriodComputeResultService {

	@Autowired
	private RobGoodsPeriodComputeResultDao robGoodsPeriodComputeResultDao;

	public List<RobGoodsPeriodComputeResultDto> queryRobGoodsPeriodComputeResultDtosByPeriodId(
			int periodId) {
		List<RobGoodsPeriodComputeResult> robGoodsInfoPeriodComputeResultList = robGoodsPeriodComputeResultDao.queryRobGoodsInfoPeriodComputeResultsByPeriodId(periodId);
		if (robGoodsInfoPeriodComputeResultList != null && !robGoodsInfoPeriodComputeResultList.isEmpty()) {
			RobGoodsPeriodComputeResult robGoodsInfoPeriodComputeResult = null;
			RobGoodsPeriodComputeResultDto robGoodsPeriodComputeResultDto = null;
			List<RobGoodsPeriodComputeResultDto> periodComputeResultDtoList = new ArrayList<RobGoodsPeriodComputeResultDto>();
			int robGoodsInfoPeriodComputeResultListSize = robGoodsInfoPeriodComputeResultList.size();
			for (int i = 0; i < robGoodsInfoPeriodComputeResultListSize; i++) {
				robGoodsInfoPeriodComputeResult = robGoodsInfoPeriodComputeResultList.get(i);
				robGoodsPeriodComputeResultDto = new RobGoodsPeriodComputeResultDto();
				CopyUtils.copy(robGoodsPeriodComputeResultDto, robGoodsInfoPeriodComputeResult);
				robGoodsPeriodComputeResultDto.setRobTimeStr(CustomDateFormatUtils.getyyyyMMddHHmmssSSS2Str(robGoodsInfoPeriodComputeResult.getRobTime()));
				periodComputeResultDtoList.add(robGoodsPeriodComputeResultDto);
			}
			return periodComputeResultDtoList;
		}
		return Collections.emptyList();
	}
	
}